package com.oa.co.listener;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.oa.co.bo.Business_tripBo;
import com.oa.co.common.R;
import com.oa.co.pojo.Business_trip;
import com.oa.co.service.BusinessTripService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @author sunXuDong
 * @data 2023/5/10
 */
@Component
@Scope("prototype")     // 注意 这里要设置成多例模式
public class Business_tripListener extends AnalysisEventListener<Business_tripBo> {

        @Autowired
        private BusinessTripService businessTripService;

    @Override
    public void invoke(Business_tripBo business_tripBo, AnalysisContext analysisContext) {
        Business_trip business_trip = new Business_trip();
        BeanUtils.copyProperties(business_tripBo,business_trip);
        System.out.println(business_trip);
        switch(business_tripBo.getT_idval()){
            case"企业项目":
                business_trip.setT_id(17);
                break;
            case"企业团建":
                business_trip.setT_id(18);
                break;
            case"企业学习":
                business_trip.setT_id(19);
                break;
        }
        R add = businessTripService.add(business_trip);
        System.out.println(business_trip);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
